package cn.hdu.liang.ch4;

public class ExceptionThread2 {
    public static void main(String[] args) {
        Runnable r = () -> {
            int x = 1 / 0;
        };
        Thread thd = new Thread(r);
        Thread.UncaughtExceptionHandler uceh;

        uceh = (t, e) -> System.out.println("Caught throwable " + e + " for thread " + t);
        thd.setUncaughtExceptionHandler(uceh);

        uceh = (Thread t, Throwable e) -> {
            System.out.println("默认未捕获异常handler");
            System.out.println("Caught throwable " + e + " for thread " + t);
        };
        thd.setDefaultUncaughtExceptionHandler(uceh);

        thd.start();
    }
}
